package com.list.test.relfinder;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;

import com.list.algorithm.KShortestPath;
import com.list.data.structure.ShortestPathResult;
import com.list.model.abstracts.BaseModel;
import com.list.model.abstracts.Initializable;
import com.list.model.specific.OntoModel;
import com.list.model.utils.RelFinderLog;

public class ListRelFinder {
	public static void main(String[] args) throws IOException {
		RelFinderLog.setLogType(RelFinderLog.DETAIL);
		
		BaseModel ontoModel = new OntoModel();
		ontoModel.loadOntology();
		ontoModel.initialize(Initializable.MEMORY_INITIAL_TYPE);
		KShortestPath shortestPath = new KShortestPath(ontoModel);
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in, "UTF-8"));
        while (true) {
            System.out.println("Input Query: ");
            String query = br.readLine();
            if (query.equals("quit")) {
                break;
            } else {
                long startTime = System.currentTimeMillis();
                ShortestPathResult kShortestPath = shortestPath.findKShortestPath(TestInstance.start, TestInstance.sink, 5, 5);
//                ShortestPathResult kShortestPath = shortestPath.findKShortestPath(TestInstance.start, TestInstance.sink, 4);
                System.out.println(kShortestPath.toString());
                long endTime = System.currentTimeMillis();
                System.out.println("\nRunning Time = " + (endTime - startTime) / 1000.0f + " sec");
            }
        }
	}
}
